#!/usr/bin/env python

import os

SETARTIST = 'exiv2 -M"set Exif.Image.Artist Ascii Camera owner, Martino Salvetti <the9ull@silix.org>" "%s"'
PRINTEXIF = 'exiv2 pr "%s"'
FILETYPE = 'file "%s"'

def ismycam(path):
    pipe = os.popen(PRINTEXIF % path)
    data = pipe.read()
    pipe.close()
    return 'FinePix S3000' in data

def thereisexif(path):
    pipe = os.popen(FILETYPE % path)
    data = pipe.read()
    pipe.close()
    return 'EXIF' in data

def setartist(path):
    os.system(SETARTIST % path)


for dirpath, dirnames, filenames in os.walk(os.curdir):
    for filename in filenames:
        filename = os.path.join(dirpath,filename)
        if thereisexif(filename):
            if ismycam(filename):
                print 'Set artist of',filename
                setartist(filename)
